package com.travel.JPA;

import com.travel.Bean.Strategy;
import org.bytedeco.opencv.presets.opencv_core;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface StrategyJPA extends JpaRepository<Strategy,Integer> {

    /**
     * 攻略向上
     *
     * @param strategyId 攻略id
     * @param upNum      全国矿工工会了
     * @return {@link Integer}
     */
    @Modifying
    @Query("update strategy set strategy_up = ?2 where id = ?1")
    Integer strategyUp(Integer strategyId, String upNum);

    /**
     * findstrategy由id
     *
     * @param strategyId 攻略id
     * @return {@link String}
     */
    @Query("select s.strategy_up from strategy s where s.id = ?1")
    String findStrategyUpById(Integer strategyId);

    /**
     * 找到所有ids
     *
     * @param strategyIds 攻略ids
     * @return {@link List}<{@link Strategy}>
     */
    @Query("select s from  strategy s where s.id in (?1)")
    List<Strategy> findAllByIds(List<Integer> strategyIds);


    /**
     * 找到攻略向上通过id
     *
     * @param strategyId 攻略id
     * @return {@link String}
     */
    @Query("select strategy_up from strategy where id = ?1")
    String findStrategy_upById(Integer strategyId);

}
